import {Component, OnInit, Input, OnChanges} from '@angular/core';
import {NzMessageService} from "ng-zorro-antd";
import {FetchService} from "../../../core/net/fetch.service";


@Component({
  selector: "app-data-panel",
  templateUrl: "./data-panel.component.html",
  styleUrls: ["./data-panel.component.scss"]
})
export class DataPanelComponent implements OnInit {
  // tslint:disable-next-line:variable-name
  private _selectManageId = '';

  @Input()
  set selectManageId(val) {
    this._selectManageId = val;
    this.queryInfo();
  }

  get selectManageId() {
    return this._selectManageId;
  }

  yslData = {total: 0, plan: 0};
  data = {wheat1: 0, wheat2: 0, wheat3: 0, corn: 0, rice: 0, other: 0};

  constructor(
    private message: NzMessageService,
    private fetchService: FetchService,
  ) {
  }

  ngOnInit() {
    this.queryInfo();
  }

  queryInfo(): void {
    // 引水量
    this.fetchService.post<any>('base/wrsReportDayManage/manageTotal', {manageId: this.selectManageId}).subscribe(res => {
      if (res) {
        this.yslData = res;
      }
    });

    // 灌溉进度
    this.fetchService.post<any>('base/wrsScheduleCropStructureIrrArea/manageTotal', {manageId: this.selectManageId}).subscribe(res => {
      this.data = res[0];
    });
  }

}
